<?php
namespace App\Http\Forms;

use App\Library\OSS;
use Kris\LaravelFormBuilder\Form;

class BannerForm extends Form
{
    public function buildForm()
    {
        $this
            ->add('image', 'image', [
                'label' => "图片",
                'rules' => 'required|string',
                'type' => 'banner',
                'help_block' => [
                    'text' => "建议尺寸694*346",
                ]
            ])
            ->add('aim', 'select', [
                'label' => "跳转目标",
                'rules' => 'required|string',
                'choices' => [
                    'url' => "指定链接",
                    'package' => "套系商品",
                    'good' => "普通商品",
                ],
            ])
            ->add('shop_id', 'select', [
                'label' => "所属门店",
                'rules' => 'required|integer',
                'choices' => $this->getData('shop'),
            ])
            ->add('link_id', 'linkage', [
                'label' => "链接的商品",
                'rules' => 'required|integer',
                'attr' => ['class' => "form-control select2"],
                'url' => route('admin.search_shop_good'),
                'choices' => [],
                'power' => "shop_id",
                'help_block' => [
                    'text' => "与跳转地址填写一个即可，都填写跳转地址为准。",
                ],
            ])
            ->add('url', 'text', [
                'label' => "跳转地址",
                'rules' => 'nullable',
            ])
            ->add('sort', 'text', [
                'label' => "排序权重",
                'rules' => 'nullable',
            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '保存',
            ]);
    }
}
